<?php
/**
  * 系統名稱: Lotto 系統
  * 檔案說明: 專案管理-修改
  * $Author$
  * $Id$
  *
  */
set_time_limit(0);
$strWeb = $_SERVER[argv][1];
$NowTime = time();
$strNum = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49";
$strBType = "4,5,6,7,8,9,10,11,12,13,14,17,18,19,20,27,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43";
$_SESSION["Admin_Info"] -> Account = "System";

$strLogError = $strWeb."Time: ".date("Y-m-d H:i:s")."\n";
$_isDBExist = "no";

$_SERVER["DOCUMENT_ROOT"] = "/home/share/www/".$strWeb."/secure";
include("/home/share/www/SourceSite-utf8/secure/config.inc.php");
include(__Root_Path."/config.inc.php");
include(__DBConnect_File);
if($_strLogErr != ""){
	@mysql_close($$_Conn);
	exit($strLogError.$_strLogErr);
}

include(__Modules_Path."/Gamble.lib.php");
$arrGame = getNewGambleData(1, 0);
if($arrGame === false){
	$strLogError .= $GLOBALS["errormessage"]."\n";
	$strLogError .= $GLOBALS["errorhidden"]."\n";
	@mysql_close($$_Conn);
	exit($strLogError);
}elseif(sizeof($arrGame) == 0){
	$strLogError .= $strWeb." No Data!\n";
	@mysql_close($$_Conn);
	exit($strLogError);
}

$arrD = split("-", $arrGame["GameDate"]);
$arrT = split(":", $arrGame["EndGameTime"]);
$arrST = split(":", $arrGame["EndGameTimeSN"]);
$intT = mktime($arrT[0], $arrT[1], $arrT[2], $arrD[1], $arrD[2], $arrD[0]);
$intST = mktime($arrST[0], $arrST[1], $arrST[2], $arrD[1], $arrD[2], $arrD[0]);

if($NowTime >= $intT && $NowTime <= ($intT + 180)){
	PMA_mysql_query("BEGIN", $_ConnMaster);
	if(!StopAllBetTodayGame($arrGame["ID"], $arrGame["LottoID"], $strBType, 1, 1, $strNum)){
		PMA_mysql_query("ROLLBACK", $_ConnMaster);
		$strLogError .= $GLOBALS["errormessage"]."\n";
		$strLogError .= $GLOBALS["errorhidden"]."\n";
	}elseif(!StopAllBetTodayGame($arrGame["ID"], $arrGame["LottoID"], "21,22,23,24,25,26", 1, 1, $strNum)){
		PMA_mysql_query("ROLLBACK", $_ConnMaster);
		$strLogError .= $GLOBALS["errormessage"]."\n";
		$strLogError .= $GLOBALS["errorhidden"]."\n";
	}else{
		PMA_mysql_query("COMMIT", $_ConnMaster);
		$strLogError .= "NN OK!\n\n";
	}
}

if($NowTime >= $intST && $NowTime <= ($intST + 180)){
	PMA_mysql_query("BEGIN", $_ConnMaster);
	if(!StopAllBetTodayGame($arrGame["ID"], $arrGame["LottoID"], "1,2,3,16", 1, 1, $strNum)){
		PMA_mysql_query("ROLLBACK", $_ConnMaster);
		$strLogError .= $GLOBALS["errormessage"]."\n";
		$strLogError .= $GLOBALS["errorhidden"]."\n";
	}else{
		PMA_mysql_query("COMMIT", $_ConnMaster);
		$strLogError .= "SN OK!\n\n";
	}
}
@mysql_close($$_Conn);
$strLogError .= $strWeb."Time: ".date("Y-m-d H:i:s")." End\n\n";
exit($strLogError);
?>